#include <Ice\Ice.h>
#include "Hello.h"

using namespace std;
using namespace Robot;

class HellClient : public Ice::Application
{
public:
	HellClient();
	virtual int run(int argc, char* argv[]);
};

HellClient::HellClient()
{
	//Ice::Application(Ice::NoSignalHandling);
}

int HellClient::run(int argc, char* argv[])
{
	if (argc > 1)
	{
		cerr << appName() << " : too many arguments!" << endl;
		return 0;
	}
	HelloPrx hellotcp = HelloPrx::checkedCast(
		communicator()->stringToProxy("hello"));
	if (!hellotcp)
	{
		cerr << argv[0] << " invalid proxy!" << endl;
		return 0;
	}
	for (int i=0; i<100; i++)
	{
		IceUtil::ThreadControl::sleep(IceUtil::Time::milliSeconds(10));
		hellotcp->sayHello(100-i);
		printf("[%d] sayHello();\n", i);
	}
	//hellotcp->shutdown();

	return 0;
}

int main(int argc, char* argv[]) {
	printf("Start RobotClient...\n");
	HellClient app;
	return app.main(argc, argv, "cNode.cfg");
}

